package com.hzit.controller;

import com.hzit.entity.PageResult;
import com.hzit.entity.R;
import com.hzit.entity.Student;
import com.hzit.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

// @Controller
@RestController     // 相当于：@Controller + @ResponseBody
@RequestMapping("/student")
public class StudentController {
	@Autowired
	private IStudentService studentService;
	//1. 列表学生
	@GetMapping("/list")
	//@ResponseBody           //将方法返回的R对象转换为json串
	public R list(){
		List<Student> studentList = studentService.findAll();
		return R.ok(studentList);
	}
	//2. 分页查询
	@GetMapping("/findByPage")
	public R findByPage( int page, int pageSize){
		PageResult<Student> pr = studentService.findByPage(page,pageSize);
		return R.ok(pr);
	}
}
